<?php

declare(strict_types=1);

namespace Plugin\Attractions\Inspection\Model\Inspection_exception;

use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\DbConnection\Model\Model;
use Plugin\Attractions\Inspection\Model\Inspection_exception_result\InspectionExceptionResult;

/**
 * @property int $id ID
 * @property int $type 事件类型1故障2告警
 * @property string $date 异常时间
 * @property string $content 事件内容/描述
 * @property int $status 处理状态 1已处理 2未处理 3已接收
 * @property array $inspector 巡检人
 * @property array $devices 巡检设备
 * @property \Carbon\Carbon $start_time 巡检开始时间
 * @property \Carbon\Carbon $end_time 巡检结束时间
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class InspectionException extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'inspection_exception';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'type', 'date', 'content', 'status', 'inspector', 'devices', 'start_time', 'end_time', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'type' => 'integer', 'status' => 'integer', 'inspector' => 'array', 'devices' => 'array', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function result(): HasMany
    {
        return $this->hasMany(InspectionExceptionResult::class, 'inspection_record_id', 'id');
    }
}
